/*年轻人，只管向前看，不要管自暴自弃者的话*/

import 'mqtt_manager.dart';

///create by itz on 2023/11/16 11:47
///desc : {"sid":"1231651234229","cmd":"assign_doctor","data":null,"timestamp":1695777782118}
class MqttData<T> {
  String? sid;

  /// cmd：confirmed app端用户待确认发起问诊; assign_doctor 分配医生; hang_up 视频问诊挂断;
  /// under_treatment 就诊中(医生接入); app_online 会向tv端推送app在线状态收到指令后进行下一步视频问诊流程
  String? cmd;
  dynamic? data;
  int? timestamp;

  MqttData({this.sid, this.cmd, this.data, this.timestamp});

  MqttData.fromJson(Map<String, dynamic> json) {
    sid = json['sid'];
    cmd = json['cmd'];
    if (cmd == MqttManager.cmdUnderTreatment) {
      data = TreatmentData.fromJson(json['data']);
    } else {
      data = json['data'];
    }
    timestamp = json['timestamp'];
  }

  @override
  String toString() {
    return 'MqttData{sid: $sid, cmd: $cmd, data: $data, timestamp: $timestamp}';
  }
}

/// 就诊中，问诊人和医生数据
class TreatmentData {
  String? name; // 问诊人名称
  int? gender; // 性别（0:女 1:男）
  int? age; // 年龄
  String? docHeadPic; // 医生头像
  String? doctorName; // 医生名称
  String? docTitle; // 医生职称
  String? hospitalName; // 医院名称
  String? departName; // 科室名称

  TreatmentData(
      {this.name,
      this.gender,
      this.age,
      this.docHeadPic,
      this.doctorName,
      this.docTitle,
      this.hospitalName,
      this.departName});

  TreatmentData.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    gender = json['gender'];
    age = json['age'];
    docHeadPic = json['docHeadPic'];
    doctorName = json['doctorName'];
    docTitle = json['docTitle'];
    hospitalName = json['hospitalName'];
    departName = json['departName'];
  }

  @override
  String toString() {
    return 'TreatmentData{name: $name, gender: $gender, age: $age, docHeadPic: $docHeadPic, doctorName: $doctorName, docTitle: $docTitle, hospitalName: $hospitalName, departName: $departName}';
  }
}
